package server

import (
	"github.com/go-kratos/kratos/v2/transport/grpc"
	"github.com/go-kratos/kratos/v2/transport/http"

	v1 "api/api/user/v1"
	"api/examples/server/service"
)

// NewHTTPServer new a HTTP server.
func NewHTTPServer(user *service.UserService) *http.Server {
	var opts []http.ServerOption
	opts = append(opts, http.Address("0.0.0.0:8000"))
	srv := http.NewServer(opts...)
	srv.HandlePrefix("/", v1.NewUserServiceHandler(user))
	return srv
}

// NewGRPCServer new a gRPC server.
func NewGRPCServer(user *service.UserService) *grpc.Server {
	var opts []grpc.ServerOption
	opts = append(opts, grpc.Address("0.0.0.0:9000"))
	srv := grpc.NewServer(opts...)
	v1.RegisterUserServiceServer(srv, user)
	return srv
}
